#!/bin/bash
# Arch Linux 自动分区脚本: 500MB /boot + 剩余空间根分区
# 警告: 此脚本会清空目标磁盘所有数据!

DISK="/dev/sda" # 目标磁盘

# 1. 创建分区表和新分区
echo "正在创建分区表..."
parted -s $DISK mklabel gpt
parted -s $DISK mkpart "EFI" fat32 1MiB 501MiB
parted -s $DISK set 1 esp on
parted -s $DISK mkpart "ROOT" ext4 501MiB 100%

# 2. 格式化分区
echo "正在格式化分区..."
mkfs.vfat ${DISK}1
mkfs.ext4 ${DISK}2

# 3. 挂载分区
echo "正在挂载分区..."
mount ${DISK}2 /mnt
mkdir -p /mnt/boot
mount ${DISK}1 /mnt/boot

echo "分区完成!"
echo "EFI 分区: ${DISK}1 (500MB) 挂载于 /mnt/boot"
echo "根分区: ${DISK}2 挂载于 /mnt"
# bash -c "$(curl -fsSL https://gitee.com/hevey88/install_script/raw/main/archlinux_parted.sh)"
